#ifndef ADRESS_H
#define ADRESS_H

#include <iostream>
using namespace std;
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>

//#define M_PI  3.14159265358979224
enum units
{
    KM, M, MILES, NAUTICAL_MILES
};

class Adress
{
private:
    long id;
    string continent;
    string country;
    string town;
    string way;
    string numero;
    string name;
    double latitude;
    double longitude;
    void trim(string & str);
    //int split(vector<string>& vecteur, string s, char separator);
    int split(string *& list, int size_list, string s, char separator);
    bool valid;

public:
    Adress();
    Adress(Adress & a);
    Adress(string s);
    ~Adress();
    void init();
    void Set_Id(long id){ this->id = id; }
    long Get_Id(){ return id; }
    void Set_Continent(string s){continent = s;};
    string Get_Continent(){return continent;};
    void Set_Country(string s){country = s;};
    string Get_Country(){return country;};
    void Set_Town(string s){town = s;};
    string Get_Town(){return town;};
    void Set_Way(string s){way = s;};
    string Get_Way(){return way;};
    void Set_Numero(string s){numero = s;};
    string Get_Numero(){return numero;};
    void Set_Name(string p){name = p;};
    string Get_Name(){return name;};
    void Set_Longitude(double l){longitude = l;};
    double Get_Longitude(){return longitude;};
    void Set_Latitude(double l){latitude = l;};
    double Get_Latitude(){return latitude;};
    string fullName;
    string Get_FullName(){return fullName;}
    void Set_FullName(string name){fullName = name;}
    bool IsValid(){ return valid; }
    void Set_Valid(bool valid){ this->valid = valid; }

    string ToString();
    void FromString(string s);

    static double calcul_dist(double Lat_Dec1, double Long_Dec1, double LatDec2, double Long_Dec2, units u = KM);
    static double calcul_dist(Adress a1, Adress a2, units u = KM);
    static double round_nplaces(double value, int to);
    static string unit2str(units unit);
    static units str2unit(string str);

    bool operator == (Adress a);
};

#endif // ADRESS_H
